package appIdeasScrumer.negocio;

import java.util.Collection;

import appIdeasScrumer.dao.CobroDAO;
import appIdeasScrumer.excepcion.DAOExcepcion;
import appIdeasScrumer.modelo.Cobro;
import appIdeasScrumer.modelo.Tarifa;

public class GestionCobro {
	
	public Collection<Cobro> listar() throws DAOExcepcion {
		CobroDAO dao = new CobroDAO();
		return dao.listar();
	}

	public Double calcularCobro(int prof, int coor, int alum) throws DAOExcepcion {
		Double subtotal=0.00;
		GestionTarifa gt = new GestionTarifa();
		Collection<Tarifa> ctarifa = gt.obtener();
		Double mprof=0.00;
		Double mcoor=0.00;
		Double malum=0.00;
		for (Tarifa t : ctarifa){
			if (t.getCodTarifa() == 1){
				malum = alum * t.getValorTarifa();
			} else if (t.getCodTarifa() == 2){
				mprof = prof * t.getValorTarifa();
			} else if (t.getCodTarifa() == 3){
				mcoor = coor * t.getValorTarifa();
			}
		}
		subtotal = mprof + mcoor + malum;
		return subtotal;
	}
	
	public void update(int cod, Double subtotal, Double igv, Double total) throws DAOExcepcion {
		CobroDAO dao = new CobroDAO();
		dao.update(cod, subtotal, igv, total);
	}	

}
